{$CLEO .cs}
{$USE CLEO+}
{$USE newOpcodes}
{$USE ini}

0000: NOP

script_name "GasIcon"

// By ArtemQa146

const
    car_gasoline = 0@
    find = 31@
    station = 30@
    blip_icon = 29@
    blip_icon_txd = 28@
    distance_1 = 27@
    dist_spawn = 170.0
    from_dist = 50.0
    to_dist = 1000.0
    r_1 = 26@
    g_1 = 25@
    b_1 = 24@
end

0AF0: 0@ = read_int_from_ini_file "cleo\Gasoline Mod.ini" section "Visual Settings" key "Nearby Gas Station Icon"
if
    0@ == 0
then
    0A93: terminate_this_custom_script
end

0390: load_txd_dictionary "GSMOD"
038F: load_texture "GSST" as 1  // Load dictionary with 0390 first
0E3C: get_texture_from_sprite 1 store_to blip_icon_txd
0391: release_textures

0AF0: r_1 = read_int_from_ini_file "cleo\Gasoline Mod.ini" section "Visual Settings" key "Map Icon R"
0AF0: g_1 = read_int_from_ini_file "cleo\Gasoline Mod.ini" section "Visual Settings" key "Map Icon G"
0AF0: b_1 = read_int_from_ini_file "cleo\Gasoline Mod.ini" section "Visual Settings" key "Map Icon B"


while true
wait 500
    if
        player.Defined(0)
    then
        if
            00DF:   actor $PLAYER_ACTOR driving
        then
            03C0: car_gasoline = actor $PLAYER_ACTOR car
            0A97: 1@ = car car_gasoline struct
            0D4E: 2@ = struct 1@ offset 0x8 size 1
            if
                08B7:   test 2@ bit 1 //   
            then
                0D4E: 2@ = struct 1@ offset 0x9 size 4
                3@ = 1000
                3@ /= 4
                if
                    001D:   3@ > 2@  // (int)
                then
                    0E12: get_vehicle Car_gasoline subclass_to 1@
                    if or
                        1@ == 0
                        1@ == 1
                        1@ == 2
                        1@ == 9
                    then

                        04C4: store_coords_to 1@ 2@ 3@ from_actor $PLAYER_ACTOR with_offset 0.0 0.0 0.0
                        4@ = false

                        for distance_1 = from_dist to to_dist step 50.0

                            if
                                0EEA: locate_char_distance_to_coordinates $PLAYER_ACTOR pos 1944.852 -1769.554 3@ radius distance_1
                            then
                                if
                                    distance_1 >= dist_spawn
                                then
                                    1@ = 1944.852
                                    2@ = -1769.554
                                    4@ = true
                                    break
                                else
                                    break
                                end
                            end

                            if
                                0EEA: locate_char_distance_to_coordinates $PLAYER_ACTOR pos -741.2739 2740.3254 3@ radius distance_1
                            then
                                if
                                    distance_1 >= dist_spawn
                                then
                                    1@ = -741.2739
                                    2@ = 2740.3254
                                    4@ = true
                                    break
                                else
                                    break
                                end
                            end

                            if
                                0EEA: locate_char_distance_to_coordinates $PLAYER_ACTOR pos 2209.816 2481.934 3@ radius distance_1
                            then
                                if
                                    distance_1 >= dist_spawn
                                then
                                    1@ = 2209.816
                                    2@ = 2481.934
                                    4@ = true
                                    break
                                else
                                    break
                                end
                            end

                            if
                                0EEA: locate_char_distance_to_coordinates $PLAYER_ACTOR pos 604.8804 1705.273 3@ radius distance_1
                            then
                                if
                                    distance_1 >= dist_spawn
                                then
                                    1@ = 604.8804
                                    2@ = 1705.273
                                    4@ = true
                                    break
                                else
                                    break
                                end
                            end

                            if
                                0EEA: locate_char_distance_to_coordinates $PLAYER_ACTOR pos -2414.49 982.081 3@ radius distance_1
                            then
                                if
                                    distance_1 >= dist_spawn
                                then
                                    1@ = -2414.49
                                    2@ = 982.081
                                    4@ = true
                                    break
                                else
                                    break
                                end
                            end

                            if
                                0EEA: locate_char_distance_to_coordinates $PLAYER_ACTOR pos -2244.623 -2561.828 3@ radius distance_1
                            then
                                if
                                    distance_1 >= dist_spawn
                                then
                                    1@ = -2244.623
                                    2@ = -2561.828
                                    4@ = true
                                    break
                                else
                                    break
                                end
                            end

                            if
                                0EEA: locate_char_distance_to_coordinates $PLAYER_ACTOR pos -1327.512 2678.107 3@ radius distance_1
                            then
                                if
                                    distance_1 >= dist_spawn
                                then
                                    1@ = -1327.512
                                    2@ = 2678.107
                                    4@ = true
                                    break
                                else
                                    break
                                end
                            end

                            if
                                0EEA: locate_char_distance_to_coordinates $PLAYER_ACTOR pos -95.1488 -1174.303 3@ radius distance_1
                            then
                                if
                                    distance_1 >= dist_spawn
                                then
                                    1@ = -95.1488
                                    2@ = -1174.303
                                    4@ = true
                                    break
                                else
                                    break
                                end
                            end

                            if
                                0EEA: locate_char_distance_to_coordinates $PLAYER_ACTOR pos -1679.982 408.9051 3@ radius distance_1
                            then
                                if
                                    distance_1 >= dist_spawn
                                then
                                    1@ = -1679.982
                                    2@ = 408.9051
                                    4@ = true
                                    break
                                else
                                    break
                                end
                            end

                            if
                                0EEA: locate_char_distance_to_coordinates $PLAYER_ACTOR pos 652.03 -571.34 3@ radius distance_1
                            then
                                if
                                    distance_1 >= dist_spawn
                                then
                                    1@ = 652.03
                                    2@ = -571.34
                                    4@ = true
                                    break
                                else
                                    break
                                end
                            end

                            if
                                0EEA: locate_char_distance_to_coordinates $PLAYER_ACTOR pos -1605.897 -2714.252 3@ radius distance_1
                            then
                                if
                                    distance_1 >= dist_spawn
                                then
                                    1@ = -1605.897
                                    2@ = -2714.252
                                    4@ = true
                                    break
                                else
                                    break
                                end
                            end

                            if
                                0EEA: locate_char_distance_to_coordinates $PLAYER_ACTOR pos -1471.48 1864.31 3@ radius distance_1
                            then
                                if
                                    distance_1 >= dist_spawn
                                then
                                    1@ = -1471.48
                                    2@ = 1864.31
                                    4@ = true
                                    break
                                else
                                    break
                                end
                            end

                            if
                                0EEA: locate_char_distance_to_coordinates $PLAYER_ACTOR pos 1596.5 2199.1 3@ radius distance_1
                            then
                                if
                                    distance_1 >= dist_spawn
                                then
                                    1@ = 1596.5
                                    2@ = 2199.1
                                    4@ = true
                                    break
                                else
                                    break
                                end
                            end

                            if
                                0EEA: locate_char_distance_to_coordinates $PLAYER_ACTOR pos 2145.9 2748.16 3@ radius distance_1
                            then
                                if
                                    distance_1 >= dist_spawn
                                then
                                    1@ = 2145.9
                                    2@ = 2748.16
                                    4@ = true
                                    break
                                else
                                    break
                                end
                            end

                            if
                                0EEA: locate_char_distance_to_coordinates $PLAYER_ACTOR pos 2642.11 1106.53 3@ radius distance_1
                            then
                                if
                                    distance_1 >= dist_spawn
                                then
                                    1@ = 2642.11
                                    2@ = 1106.53
                                    4@ = true
                                    break
                                else
                                    break
                                end
                            end

                            if
                                0EEA: locate_char_distance_to_coordinates $PLAYER_ACTOR pos 2117.42 920.42 3@ radius distance_1
                            then
                                if
                                    distance_1 >= dist_spawn
                                then
                                    1@ = 2117.42
                                    2@ = 920.42
                                    4@ = true
                                    break
                                else
                                    break
                                end
                            end

                            if
                                0EEA: locate_char_distance_to_coordinates $PLAYER_ACTOR pos 1381.68 456.26 3@ radius distance_1
                            then
                                if
                                    distance_1 >= dist_spawn
                                then
                                    1@ = 1381.68
                                    2@ = 456.26
                                    4@ = true
                                    break
                                else
                                    break
                                end
                            end

                            if
                                0EEA: locate_char_distance_to_coordinates $PLAYER_ACTOR pos 1005.3403 -936.0178 3@ radius distance_1
                            then
                                if
                                    distance_1 >= dist_spawn
                                then
                                    1@ = 1005.3403
                                    2@ = -936.0178
                                    4@ = true
                                    break
                                else
                                    break
                                end
                            end


                        end

                        if
                            4@ == true
                        then
                            0E2A: add_cleo_blip blip_icon_txd position 1@ 2@ is_short 0 RGBA r_1 g_1 b_1 255 store_to blip_icon

                            distance_1 += 50.0

                            repeat
                            wait 0
                            if
                                056E:   car car_gasoline defined
                            then
                                if
                                    00DB:   actor $PLAYER_ACTOR in_car car_gasoline
                                then
                                    0A97: 4@ = car car_gasoline struct
                                    0D4E: 5@ = struct 4@ offset 0x9 size 4
                                    6@ = 1000
                                    6@ /= 4
                                    if
                                        001D:   6@ > 5@  // (int)
                                    then
                                        04C4: store_coords_to 4@ 4@ 3@ from_actor $PLAYER_ACTOR with_offset 0.0 0.0 0.0
                                        if or
                                            0EEA: locate_char_distance_to_coordinates $PLAYER_ACTOR pos 1@ 2@ 3@ radius 150.0
                                            not locate_char_distance_to_coordinates $PLAYER_ACTOR pos 1@ 2@ 3@ radius distance_1
                                        then
                                            break
                                        end
                                    else
                                        break
                                    end
                                else
                                    break
                                end
                            else
                                break
                            end
                            until not player.Defined(0)
                            0E2B: remove_cleo_blip blip_icon
                        end
                    end
                end
            end
        end
    end
end